package com.youlu.campus.web.activity;

import com.youlu.campus.activity.entity.UserLotteryRecord;
import com.youlu.campus.activity.entity.UserLotteryRecordQueryVo;
import com.youlu.campus.activity.service.UserLotteryRecordService;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 奖品服务接口
 *
 * @Description: ActivityLotteryPrizeController
 * @Date 2025/7/31
 * @module ActivityLotteryPrizeController
 * @author: su
 */
@Slf4j
@RestController
@RequestMapping("/api/user-lottery/record")
public class UserLotteryRecordController {

    @Autowired
    private UserLotteryRecordService userLotteryRecordService;


    /**
     * 获取用户抽奖记录
     *
     * @param paramVo
     * @return
     */
    @GetMapping("/find-list")
    public QResult<Page<UserLotteryRecord>> findListByActivityId(UserLotteryRecordQueryVo paramVo) {
        log.info("findListByActivityId paramVo:{}", paramVo);
        String userId = RequestContext.getUserId();
        Page<UserLotteryRecord> list = userLotteryRecordService.findListByActivityIdAndUserId(userId, paramVo);
        return QResult.success(list);
    }

    /**
     * 获取最新抽奖记录
     *
     * @param activityId
     * @return
     */
    @GetMapping("/find-new")
    public QResult<List<UserLotteryRecord>> findNew(@RequestParam String activityId) {
        log.info("findNew activityId:{}", activityId);
        List<UserLotteryRecord> list = userLotteryRecordService.findNew(activityId);
        return QResult.success(list);
    }
}
